package we_chat_group

import (
	"fmt"
	"github.com/eatmoreapple/openwechat"
	"server/src/global"
	"server/src/model"
	"server/src/model/response"
	"strconv"
)

const (
	NOTSCORE           = "not score"
	INVALIDINSTRUCTION = "Invalid instruction"
)

func invalidInstructionRes(msg *openwechat.Message, sender *openwechat.User) {
	backInfo := "@" + sender.NickName + " 无效指令"
	msg.ReplyText(backInfo)
}
func bettingFailNotOpenTimeRes(msg *openwechat.Message, sender *openwechat.User) {
	backInfo := "@" + sender.NickName + " 答题失败," + "本期停止作答"
	msg.ReplyText(backInfo)
}
func bettingFailRes(msg *openwechat.Message, sender *openwechat.User) {
	backInfo := "@" + sender.NickName + " 答题失败"
	msg.ReplyText(backInfo)
}

func bettingNotScoreRes(msg *openwechat.Message, sender *openwechat.User, score float64) {
	backInfo := "@" + sender.NickName + " 积分不足"
	backInfo = backInfo + "\n" + "💰" + fmt.Sprintf("%.2f", score)
	msg.ReplyText(backInfo)
}

func bettingSuccessRes(msg *openwechat.Message, sender *openwechat.User, score float64, bettingInfo *response.OurBgCurrentBetting) {
	backInfo := "@" + sender.NickName + " ✅答题成功"
	for _, v := range bettingInfo.BgGuessNums {
		switch v.PlayingMethod {
		case global.BG_JIAO:
			backInfo = backInfo + "\n" + strconv.Itoa(v.Num[0]) + strconv.Itoa(v.Num[1])
			backInfo += "角/" + strconv.FormatFloat(v.Integral, 'f', 0, 64)

		case global.BG_ZHENG:
			backInfo = backInfo + "\n" + strconv.Itoa(v.Num[0])
			backInfo += "正/" + strconv.FormatFloat(v.Integral, 'f', 0, 64)

		case global.BG_FAN:
			backInfo = backInfo + "\n" + strconv.Itoa(v.Num[0])
			backInfo += "番/" + strconv.FormatFloat(v.Integral, 'f', 0, 64)

		case global.BG_NIAN:
			backInfo = backInfo + "\n" + strconv.Itoa(v.Num[0]) + "念" + strconv.Itoa(v.Num[1])
			backInfo += "/" + strconv.FormatFloat(v.Integral, 'f', 0, 64)
		}

	}
	backInfo = backInfo + "\n" + "💰" + fmt.Sprintf("%.2f", score)
	msg.ReplyText(backInfo)
}

func appleSuccessRes(msg *openwechat.Message, sender *openwechat.User, appMsg string) {
	backInfo := "@" + sender.NickName + " "
	backInfo += appMsg
	msg.ReplyText(backInfo)
}

func appleFailRes(msg *openwechat.Message, sender *openwechat.User, appMsg string) {
	backInfo := "@" + sender.NickName + " "
	backInfo += appMsg + " 申请失败"
	msg.ReplyText(backInfo)
}

// 今日详情
func todaysDetails(msg *openwechat.Message, sender *openwechat.User, userinfo *model.WeChatGroupUser, phase float64) {
	backInfo := "@" + sender.NickName + " " + "今日详情\n"
	backInfo += "今日💦:" + strconv.FormatFloat(userinfo.RunWater, 'f', 2, 64) + "\n"
	backInfo += "已回💦:" + strconv.FormatFloat(userinfo.ReturnedWater, 'f', 2, 64) + "\n"
	backInfo += "未回💦:" + strconv.FormatFloat(userinfo.RunWater-userinfo.ReturnedWater, 'f', 2, 64) + "\n"
	backInfo += "今日上💰:" + strconv.FormatFloat(userinfo.UpwardDivision, 'f', 2, 64) + "\n"
	backInfo += "今日下💰:" + strconv.FormatFloat(userinfo.LowerDivision, 'f', 2, 64) + "\n"
	backInfo += "今日盈亏:" + strconv.FormatFloat(phase, 'f', 2, 64) + "\n"
	backInfo += "剩余💰:" + strconv.FormatFloat(userinfo.SumScore, 'f', 2, 64)

	msg.ReplyText(backInfo)
}
